Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1.13 #651

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

2.1.13 #651

wants to merge 2 commits into from

Conversation

mjadach-iv
Copy link
Contributor

@mjadach-iv mjadach-iv commented Dec 3, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced dropdown menu handling in the ConnectNode component.
    • Enhanced button interactivity in the PingModal based on pinging status.
  • UI Improvements

    • Adjusted heights of various components (ConnectNode, NotificationBar, AppBar, LoadingOverlay) for a more streamlined layout.
    • Updated styles for the drawer component to improve responsiveness.
  • Bug Fixes

    • Improved control flow for ping operations, preventing multiple simultaneous requests.
  • Chores

    • Removed the PingPage component to streamline functionality.

Copy link

coderabbitai bot commented Dec 3, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several modifications across multiple components, primarily focusing on UI adjustments and state management enhancements. Key changes include reduced heights in various styled components, the addition of menu handling functions in the ConnectNode component, and the introduction of a new pinging state in the PingModal component. The pingNodeThunk functionality is updated to manage active ping requests more effectively, replacing the previous array-based tracking with a key-value mapping for ongoing pings. Overall, the changes aim to refine the user interface and improve the responsiveness of components.

Changes

File Change Summary
src/components/ConnectNode/index.tsx Adjusted height of Container from 59px to 54px; added handleOpenMenu and handleCloseMenu functions; updated handleContainerClick logic.
src/components/Modal/node/PingModal.tsx Added pinging state from Redux to manage IconButton disabled state based on pinging status.
src/components/NotificationBar/index.tsx Adjusted height and width of Container from 59px to 54px.
src/components/Overlays/LoadingOverlay.tsx Updated margin-left and width calculations for Overlay based on drawer state.
src/future-hopr-lib-components/Layout/drawer.tsx Updated drawer dimensions and styling; modified rendering logic for StyledListSubheader.
src/future-hopr-lib-components/Layout/index.tsx Adjusted margin-top for Content; refined navigation drawer state management.
src/future-hopr-lib-components/Navbar/navBar.tsx Reduced AppBar height from 60px to 55px.
src/future-hopr-lib-components/Section/index.tsx Removed max-width from Content styled component.
src/pages/node/info/index.tsx Added style={{paddingTop: '2px'}} to IconButton.
src/pages/node/ping.tsx Deleted PingPage component.
src/store/slices/node/actionsAsync.ts Updated pingNodeThunk to manage pinging state for active pings, removing previous fulfilled logic.
src/store/slices/node/initialState.ts Replaced pings array with pinging object for tracking active pings.

Possibly related PRs

  • Overall improvements in node admin for HOPRd 2.1.5 #640: The changes in the WithdrawModal component include updates to state management and validation logic that may relate to the overall user experience improvements in the node admin interface, which aligns with the UI adjustments made in the ConnectNode component of the main PR.

Suggested reviewers

  • esterlus
  • Jaguaras

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (4)
src/future-hopr-lib-components/Layout/index.tsx (1)

20-21: LGTM: Improved maintainability with constants

Good improvements:

  • Using imported constants for drawer dimensions improves maintainability
  • Margin adjustments are consistent with navbar height changes

Consider adding a comment explaining the relationship between these layout dimensions and their impact on the overall UI structure. This would help future maintainers understand the interdependencies.

Also applies to: 37-37, 42-42

src/components/Modal/node/PingModal.tsx (1)

127-128: Simplify the disabled and pending prop logic

The disabled and pending props have duplicate conditions. Consider extracting the common condition to improve maintainability.

-        disabled={props.disabled || pinging[peerId]}
-        pending={disableButton || pinging[peerId]}
+        const isPinging = pinging[peerId];
+        disabled={props.disabled || isPinging}
+        pending={disableButton || isPinging}
src/store/slices/node/initialState.ts (1)

182-184: Consider using boolean type instead of literal true

The type definition could be more flexible by using boolean instead of the literal true type.

   pinging: {
-    [peerId: string]: true
+    [peerId: string]: boolean
   };
src/store/slices/node/actionsAsync.ts (1)

1447-1453: Add missing semicolon

There's a missing semicolon after the peerId declaration.

-    const peerId = action.meta.arg.peerId
+    const peerId = action.meta.arg.peerId;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f1a205e and e6ccdf8.

📒 Files selected for processing (12)
  • src/components/ConnectNode/index.tsx (1 hunks)
  • src/components/Modal/node/PingModal.tsx (2 hunks)
  • src/components/NotificationBar/index.tsx (1 hunks)
  • src/components/Overlays/LoadingOverlay.tsx (1 hunks)
  • src/future-hopr-lib-components/Layout/drawer.tsx (4 hunks)
  • src/future-hopr-lib-components/Layout/index.tsx (2 hunks)
  • src/future-hopr-lib-components/Navbar/navBar.tsx (1 hunks)
  • src/future-hopr-lib-components/Section/index.tsx (0 hunks)
  • src/pages/node/info/index.tsx (1 hunks)
  • src/pages/node/ping.tsx (0 hunks)
  • src/store/slices/node/actionsAsync.ts (1 hunks)
  • src/store/slices/node/initialState.ts (2 hunks)
💤 Files with no reviewable changes (2)
  • src/future-hopr-lib-components/Section/index.tsx
  • src/pages/node/ping.tsx
✅ Files skipped from review due to trivial changes (1)
  • src/pages/node/info/index.tsx
🔇 Additional comments (9)
src/future-hopr-lib-components/Navbar/navBar.tsx (1)

19-19: LGTM: Height adjustment is consistent

The navbar height reduction to 55px aligns with the layout adjustments seen across other components.

src/components/NotificationBar/index.tsx (1)

22-23: LGTM! Consistent styling update

The height and width adjustments align with similar changes across other components, maintaining UI consistency.

src/components/ConnectNode/index.tsx (2)

26-26: LGTM! Consistent styling update

The height adjustment aligns with similar changes in NotificationBar component.


Line range hint 155-182: LGTM! Well-implemented menu handling

The menu handling implementation includes:

  • Clean separation of concerns with dedicated open/close handlers
  • Proper cleanup of event listeners
  • Correct handling of click outside events
src/future-hopr-lib-components/Layout/drawer.tsx (4)

20-21: LGTM! Drawer width constants updated

The drawer width constants have been adjusted to provide a more compact layout.


84-96: LGTM! Improved header styling

The StyledListSubheader changes provide better alignment and spacing:

  • Reduced height for a more compact look
  • Added proper icon spacing
  • Improved font size for better readability

100-115: LGTM! Enhanced list item styling

The StyledListItemButton changes provide better visual hierarchy:

  • Adjusted height and padding for better spacing
  • Updated icon dimensions for consistency
  • Improved typography settings

218-228: LGTM! Improved group header rendering

The conditional rendering of group headers has been enhanced with proper icon handling for both open and closed states.

src/components/Modal/node/PingModal.tsx (1)

26-26: LGTM: Redux state integration for ping tracking

The addition of the pinging state from the Redux store enables proper tracking of ongoing ping operations.

Comment on lines +45 to 46
margin-left: 220px;
width: calc( 100% - 240px - 32px);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix inconsistent width calculation

There's an inconsistency in the dimensions:

  • margin-left is set to 220px
  • But the width calculation still uses 240px: calc(100% - 240px - 32px)

This mismatch could cause layout issues. The width calculation should be updated to match the new margin.

  .drawerOpen .Overlay {
    margin-left: 220px;
-   width: calc( 100% - 240px - 32px);
+   width: calc( 100% - 220px - 32px);
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
margin-left: 220px;
width: calc( 100% - 240px - 32px);
margin-left: 220px;
width: calc( 100% - 220px - 32px);

Comment on lines 1455 to 1470
if (action.meta.arg.apiEndpoint !== state.apiEndpoint) return;
if (action.payload) {
const pingExists = state.pings.findIndex((ping) => ping.peerId === action.payload?.peerId);

if (pingExists) {
state.pings[pingExists] = {
latency: action.payload.latency,
peerId: action.payload.peerId,
reportedVersion: action.payload.reportedVersion,
};
} else {
state.pings.push({
latency: action.payload.latency,
peerId: action.payload.peerId,
reportedVersion: action.payload.reportedVersion,
});
}
const peerId = action.meta.arg.peerId;
if(peerId && state.pinging[peerId]){
const next = {...state.pinging}
delete next[peerId]
state.pinging = next;
}
});
builder.addCase(pingNodeThunk.rejected, (state, action) => {
if (action.meta.arg.apiEndpoint !== state.apiEndpoint) return;
const peerId = action.meta.arg.peerId;
if(peerId && state.pinging[peerId]){
const next = {...state.pinging}
delete next[peerId]
state.pinging = next;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Reduce code duplication in ping state management

The fulfilled and rejected cases contain identical code for removing the ping status. Consider extracting this logic into a helper function.

+  const removePingStatus = (state: typeof initialState, peerId: string) => {
+    if (peerId && state.pinging[peerId]) {
+      delete state.pinging[peerId];
+    }
+  };

   builder.addCase(pingNodeThunk.fulfilled, (state, action) => {
     if (action.meta.arg.apiEndpoint !== state.apiEndpoint) return;
     const peerId = action.meta.arg.peerId;
-    if(peerId && state.pinging[peerId]){
-      const next = {...state.pinging}
-      delete next[peerId]
-      state.pinging = next;
-    }
+    removePingStatus(state, peerId);
   });

   builder.addCase(pingNodeThunk.rejected, (state, action) => {
     if (action.meta.arg.apiEndpoint !== state.apiEndpoint) return;
     const peerId = action.meta.arg.peerId;
-    if(peerId && state.pinging[peerId]){
-      const next = {...state.pinging}
-      delete next[peerId]
-      state.pinging = next;
-    }
+    removePingStatus(state, peerId);
   });

Additionally, the object spread operation is unnecessary since we can directly modify the state object in Redux Toolkit.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (action.meta.arg.apiEndpoint !== state.apiEndpoint) return;
if (action.payload) {
const pingExists = state.pings.findIndex((ping) => ping.peerId === action.payload?.peerId);
if (pingExists) {
state.pings[pingExists] = {
latency: action.payload.latency,
peerId: action.payload.peerId,
reportedVersion: action.payload.reportedVersion,
};
} else {
state.pings.push({
latency: action.payload.latency,
peerId: action.payload.peerId,
reportedVersion: action.payload.reportedVersion,
});
}
const peerId = action.meta.arg.peerId;
if(peerId && state.pinging[peerId]){
const next = {...state.pinging}
delete next[peerId]
state.pinging = next;
}
});
builder.addCase(pingNodeThunk.rejected, (state, action) => {
if (action.meta.arg.apiEndpoint !== state.apiEndpoint) return;
const peerId = action.meta.arg.peerId;
if(peerId && state.pinging[peerId]){
const next = {...state.pinging}
delete next[peerId]
state.pinging = next;
}
const removePingStatus = (state: typeof initialState, peerId: string) => {
if (peerId && state.pinging[peerId]) {
delete state.pinging[peerId];
}
};
builder.addCase(pingNodeThunk.fulfilled, (state, action) => {
if (action.meta.arg.apiEndpoint !== state.apiEndpoint) return;
const peerId = action.meta.arg.peerId;
removePingStatus(state, peerId);
});
builder.addCase(pingNodeThunk.rejected, (state, action) => {
if (action.meta.arg.apiEndpoint !== state.apiEndpoint) return;
const peerId = action.meta.arg.peerId;
removePingStatus(state, peerId);
});

@mjadach-iv mjadach-iv marked this pull request as draft December 11, 2024 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When pinging from a table, the pending status on the button should be persistent
1 participant